// 闭包实现
const getSingle = function(fn) {
  let result;
  return function() {
    return result || (result = fn.apply(this, arguments));
  }
}

// 使用Proxy拦截
const proxy = function(fn) {
  let result;
  const handler = {
    construct: function() {
      if(!result) {
        result = Reflect.construct(fn, arguments);
      }
      return result;
    }
  }
  return new Proxy(fn, handler);
}